package com.serviceprovider.business.module.report.valueobjects;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.sp.transaction.model.TransactionUserAmount;

//~--- JDK imports ------------------------------------------------------------

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AllFeeTransactionRecord {
    private Map<String, Integer> fees = new HashMap<String, Integer>();
    private Integer              amount;

    // Added to show custom label
    private Integer                     customLabel1;
    private Integer                     customLabel2;
    private String                      customerName;
    private Integer                     customerSSN;
    private double                      serviceFee;
    private List<TransactionUserAmount> transactionUserAmounts;

    public AllFeeTransactionRecord() {}

    public void setCustomerSSN(Integer customerSSN) {
        this.customerSSN = customerSSN;
    }

    public Integer getCustomerSSN() {
        return customerSSN;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setFees(Map<String, Integer> fees) {
        this.fees = fees;
    }

    public Map<String, Integer> getFees() {
        return fees;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setTransactionUserAmounts(List<TransactionUserAmount> transactionUserAmounts) {
        this.transactionUserAmounts = transactionUserAmounts;
    }

    public List<TransactionUserAmount> getTransactionUserAmounts() {
        return transactionUserAmounts;
    }

    public Map<Integer, Integer> getAmountOfUser() {

        // FIXME: [Performance] amounts map will be created so many times
        Map<Integer, Integer> amounts = new HashMap<Integer, Integer>();

        for (TransactionUserAmount transUserAmount : transactionUserAmounts) {
            amounts.put(transUserAmount.getUserId(), transUserAmount.getAmount());
        }

        return amounts;
    }

    public void setServiceFee(double serviceFee) {
        this.serviceFee = serviceFee;
    }

    public double getServiceFee() {
        return serviceFee;
    }

    public Double getTotalFee() {
        Double total = 0.0;

        for (Integer fee : fees.values()) {
            total += fee;
        }

        total += serviceFee;

        for (TransactionUserAmount transAmount : transactionUserAmounts) {
            total += transAmount.getAmount();
        }

        return total;
    }

    public Double getCustomerBalance() {
        return amount - getTotalFee();
    }

    public Integer getCustomLabel1() {
        return customLabel1;
    }

    public void setCustomLabel1(Integer customLabel1) {
        this.customLabel1 = customLabel1;
    }

    public Integer getCustomLabel2() {
        return customLabel2;
    }

    public void setCustomLabel2(Integer customLabel2) {
        this.customLabel2 = customLabel2;
    }
}



